package exercise;

public class EX03_Q30 {

	public static void main(String[] args) {
		// #30
		// while -----------------------------------------------------------------------
		int i = 1;
		int j = 1;
		int k = 1;

		System.out.println("              Multiplication Table");
		System.out.print("   ");
		while (i <= 9) {
			System.out.print("    " + i);
			++i;
		}
		System.out.println("\n------------------------------------------------");

		while (j <= 9) {
			System.out.print(j + " |");
			while (k <= 9) {
				int r = j * k;
				if (r < 10) {
					System.out.print("    " + r);
				} else {
					System.out.print("   " + r);
				}
				++k;
			}
			System.out.println();
			++j;
			k = 1;
		}

		System.out.println("================================================="); // 구분선

		// for ------------------------------------------------------------------------------
		System.out.println("              Multiplication Table");
		System.out.print("   ");
		for (i = 1; i <= 9; ++i) {
			System.out.print("    " + i);
		}
		System.out.println("\n------------------------------------------------");

		for (j = 1; j <= 9; ++j) {
			System.out.print(j + " |");
			for (k = 1; k <= 9; ++k) {
				int r = j * k;
				if (r < 10) {
					System.out.print("    " + r);
				} else {
					System.out.print("   " + r);
				}
			}
			System.out.println();
		}		

	}

}
